package com.hdsx.restful.glzt.roadline.dmdx.rest;

import java.util.List;

import javax.annotation.Resource;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import org.springframework.stereotype.Service;

import com.hdsx.restful.glzt.roadline.dmdx.bean.Dmdx;
import com.hdsx.restful.glzt.roadline.dmdx.service.DmdxService;
import com.hdsx.restful.util.EasyUI;

@Path("/dmdx")
@Service
public class DmdxRestServer {
	@Resource(name="dmdxServiceImpl")
	private DmdxService dmdxService;

	/**
	 * http://192.168.0.103:8080/restful/rest/dmdx/list?lxdm=H108&page=0&rows=10
	 * @param lxdm
	 * @param page
	 * @param rows
	 * @return
	 */
	@GET
	@Path("/list")
	@Produces(MediaType.APPLICATION_JSON)
	public EasyUI<Dmdx> queryList(@QueryParam("lxdm") String lxdm,@QueryParam("page") int page,@QueryParam("rows") int rows) {
		EasyUI<Dmdx> uiPage = new EasyUI<Dmdx>(page, rows);
		int count =dmdxService.queryCountByParameter(lxdm);
		List<Dmdx> servicefws= dmdxService.queryByParameter(lxdm,uiPage.getBegin(),uiPage.getEnd());
		uiPage.setTotal(count);
		uiPage.setRows(servicefws);
		return uiPage;
	}
	
	@GET
	@Path("/queryDmdxString")
	@Produces(MediaType.APPLICATION_JSON)
	public String queryDmdxString(@QueryParam("id") String id)
	{
		return dmdxService.queryDmdxString(id);
	}
}
